home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / vbmail / mailbox.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-09-06  |  7.4 KB  |  258 lines

  1. VERSION 2.00
  2. Begin Form MailBox 
  3.    BackColor       =   &H00FFFF00&
  4.    Caption         =   "Mailbox"
  5.    ClientHeight    =   4650
  6.    ClientLeft      =   1065
  7.    ClientTop       =   1530
  8.    ClientWidth     =   7305
  9.    FontBold        =   0   'False
  10.    FontItalic      =   0   'False
  11.    FontName        =   "MS Sans Serif"
  12.    FontSize        =   24
  13.    FontStrikethru  =   0   'False
  14.    FontUnderline   =   0   'False
  15.    Height          =   5340
  16.    Icon            =   MAILBOX.FRX:0000
  17.    Left            =   1005
  18.    LinkMode        =   1  'Source
  19.    LinkTopic       =   "Form2"
  20.    MaxButton       =   0   'False
  21.    ScaleHeight     =   4650
  22.    ScaleWidth      =   7305
  23.    Top             =   900
  24.    Width           =   7425
  25.    Begin TextBox MsgText 
  26.       BackColor       =   &H00FFFF00&
  27.       FontBold        =   -1  'True
  28.       FontItalic      =   0   'False
  29.       FontName        =   "MS Sans Serif"
  30.       FontSize        =   9.75
  31.       FontStrikethru  =   0   'False
  32.       FontUnderline   =   0   'False
  33.       Height          =   2295
  34.       Left            =   360
  35.       MultiLine       =   -1  'True
  36.       ScrollBars      =   2  'Vertical
  37.       TabIndex        =   2
  38.       Top             =   2070
  39.       Width           =   6645
  40.    End
  41.    Begin ListBox MailList 
  42.       BackColor       =   &H00FFFFFF&
  43.       FontBold        =   -1  'True
  44.       FontItalic      =   0   'False
  45.       FontName        =   "System"
  46.       FontSize        =   9.75
  47.       FontStrikethru  =   0   'False
  48.       FontUnderline   =   0   'False
  49.       Height          =   1230
  50.       Left            =   360
  51.       Sorted          =   -1  'True
  52.       TabIndex        =   0
  53.       Top             =   450
  54.       Width           =   6645
  55.    End
  56.    Begin Label Label3 
  57.       BackColor       =   &H00FFFF00&
  58.       BorderStyle     =   1  'Fixed Single
  59.       Caption         =   "Date     From            Subject"
  60.       FontBold        =   0   'False
  61.       FontItalic      =   0   'False
  62.       FontName        =   "Terminal"
  63.       FontSize        =   9
  64.       FontStrikethru  =   0   'False
  65.       FontUnderline   =   0   'False
  66.       Height          =   255
  67.       Left            =   360
  68.       TabIndex        =   1
  69.       Top             =   210
  70.       Width           =   6645
  71.    End
  72.    Begin Menu ID_FILE 
  73.       Caption         =   "&File"
  74.       Begin Menu ID_OPEN 
  75.          Caption         =   "&Open..."
  76.          Begin Menu ID_EDITOR 
  77.             Caption         =   "&Editor"
  78.          End
  79.          Begin Menu ID_MAILBOX 
  80.             Caption         =   "&Mailbox"
  81.          End
  82.          Begin Menu ID_MAILFILES 
  83.             Caption         =   "Mail &Files"
  84.          End
  85.       End
  86.       Begin Menu ID_REPLY 
  87.          Caption         =   "&Reply"
  88.       End
  89.       Begin Menu ID_SAVE 
  90.          Caption         =   "&Save"
  91.       End
  92.       Begin Menu sep1 
  93.          Caption         =   "-"
  94.       End
  95.       Begin Menu ID_DELETE 
  96.          Caption         =   "&Delete"
  97.       End
  98.       Begin Menu sep 
  99.          Caption         =   "-"
  100.       End
  101.       Begin Menu ID_EXIT 
  102.          Caption         =   "E&xit"
  103.       End
  104.    End
  105.    Begin Menu ID_EDIT 
  106.       Caption         =   "&Edit"
  107.       Begin Menu ID_COPY 
  108.          Caption         =   "&Copy        Ctrl+Ins"
  109.       End
  110.    End
  111. DefInt A-Z
  112. ' ---- Delete a Message from the MailList Listbox
  113. Sub DeleteMessage ()
  114.     MailList.RemoveItem MailList.ListIndex
  115.     If MailList.ListCount = 0 Then
  116.         MsgText.Text = ""
  117.         If Extension = "MSG" Then
  118.             MailPending = False
  119.             SetMailBoxIcon
  120.         End If
  121.     Else
  122.         If MailList.ListIndex = -1 Then
  123.             MailList.ListIndex = 0
  124.         End If
  125.     End If
  126.     FixMenu
  127. End Sub
  128. ' ---- Load Messages into the MailBox Whenever it is Loaded
  129. Sub Form_Load ()
  130.     RebuildMailBox
  131. End Sub
  132. ' ---- Called by VB to Paint the Form
  133. Sub Form_Paint ()
  134.     If Extension = "" Then
  135.         Extension = "MSG"
  136.         RebuildMailBox
  137.     End If
  138. End Sub
  139. ' ---- Exit from VBMAIL (if permitted)
  140. Sub Form_Unload (Cancel As Integer)
  141.     If CanExit = True Then
  142.         End
  143.     End If
  144.     Extension = ""
  145. End Sub
  146. ' ---- Edit/Copy Menu Command
  147. Sub ID_COPY_Click ()
  148.     SendKeys "^{INSERT}"
  149. End Sub
  150. ' ---- File/Delete Menu Command
  151. Sub ID_DELETE_Click ()
  152.     If MsgBox("Delete the selected message?", MB_YESNO) = IDYES Then
  153.         Kill MsgFile()
  154.         DeleteMessage
  155.     End If
  156. End Sub
  157. ' ---- Edit Menubar Selection
  158. Sub ID_EDIT_Click ()
  159.     ID_COPY.Enabled = (MsgText.SelLength > 0)
  160. End Sub
  161. ' ---- File/Open/Editor Menu Command
  162. Sub ID_EDITOR_Click ()
  163.     If Extension = "FIL" Then
  164.         LoadMailBox "MSG"
  165.     End If
  166.     Mailbox.WindowState = MINIMIZED
  167.     Editor.Show
  168.     Editor.WindowState = NORMAL
  169. End Sub
  170. ' ---- File/Exit Menu Command
  171. Sub ID_EXIT_Click ()
  172.     CanExit = True
  173.     Unload Mailbox
  174. End Sub
  175. ' ---- File/Open/Mailbox Menu Command
  176. Sub ID_MAILBOX_Click ()
  177.     LoadMailBox "MSG"
  178. End Sub
  179. ' ---- File/Open/Mail Files Menu Command
  180. Sub ID_MAILFILES_Click ()
  181.     LoadMailBox "FIL"
  182. End Sub
  183. ' ---- File/Reply Menu Command
  184. Sub ID_REPLY_Click ()
  185.     Reply.MsgDate.Caption = MsgDate
  186.     Reply.MsgFrom.Caption = MsgFrom
  187.     Reply.MsgSubj.Caption = MsgSubject
  188.     Reply.MsgText.Text = Mailbox.MsgText.Text
  189.     SetMailBoxIcon
  190.     Mailbox.WindowState = MINIMIZED
  191.     Reply.Show
  192.     Reply.ReplyText.SetFocus
  193. End Sub
  194. ' ---- File/Save Menu Command
  195. Sub ID_SAVE_Click ()
  196.     fn$ = MsgFile()
  197.     If Extension = "FIL" Then
  198.         Ext$ = "MSG"
  199.     Else
  200.         Ext$ = "FIL"
  201.     End If
  202.     Name fn$ As Left$(fn$, Len(fn$) - 3) + Ext$
  203.     DeleteMessage
  204. End Sub
  205. ' ---- Select an Entry in the MailList Listbox
  206. Sub MailList_Click ()
  207.     ' ---- Extract the data items
  208.     fn$ = Mid$(MailList.List(MailList.ListIndex), 56)
  209.     MsgFrom = Mid$(MailList.List(MailList.ListIndex), 10, 15)
  210.     MsgDate = Left$(MailList.List(MailList.ListIndex), 8)
  211.     Open MyUserId + "\" + fn$ For Input Access Read As #1
  212.     Input #1, dt$, fr$, MsgSubject, tx$
  213.     ' ---- Convert text tokens to quotes
  214.     ConvertChar tx$, Chr$(127), Chr$(34)
  215.     ' ----Build the message into the message form
  216.     Mailbox.MsgText.Text = tx$
  217.     Close #1
  218. End Sub
  219. ' ---- Intercept the Del Key on the MailList Listbox
  220. Sub MailList_KeyDown (KeyCode As Integer, Shift As Integer)
  221.     If KeyCode = KEY_DELETE And MailList.ListCount <> 0 Then
  222.         ID_DELETE_Click
  223.     End If
  224. End Sub
  225. ' --- Extract the Message Filename from the current
  226. '     MailList Listbox Entry
  227. Function MsgFile () As String
  228.     MsgFile = MyUserId + "\" + Mid$(MailList.List(MailList.ListIndex), 56)
  229. End Function
  230. ' ---- MsgText Text Box is Read-only. Prevent Cut, Paste, Delete
  231. Sub MsgText_KeyDown (KeyCode As Integer, Shift As Integer)
  232.     NoClipBrd KeyCode, Shift
  233. End Sub
  234. ' ---- MsgText Textbox is Read-Only. Intercept Keystrokes
  235. Sub MsgText_KeyPress (KeyAscii As Integer)
  236.     KeyAscii = 0
  237. End Sub
  238. ' ---- Clear and Load the MailBox Form with Messages
  239. ' ---- Extension = "MSG" or "FIL"
  240. Sub RebuildMailBox ()
  241.     ' ----Clear any existing messages
  242.     Do While i < MailList.ListCount
  243.         MailList.RemoveItem i
  244.         i = i + 1
  245.     Loop
  246.     ' ----Gather messages
  247.     fpath$ = MyUserId + "\*." + Extension
  248.     fn$ = Dir$(fpath$)
  249.     Do While fn$ <> ""
  250.         AddMessage fn$
  251.         fn$ = Dir$
  252.     Loop
  253.     If MailList.ListCount <> 0 Then
  254.         MailList.ListIndex = 0
  255.     End If
  256.     FixMenu
  257. End Sub
  258.